<template>
	<view>
		<view class='commission-details'>
			<view class='promoterHeader bg-color'>
				<view class='headerCon flex-center flex-between '>
					<view>
						<view class='name'>共提现</view>
						<view class='money'>￥<text class='num'>{{11}}</text>
						</view>
					</view>
					<view class='iconfont custom-icon-jinbi custom-icon'></view>
				</view>
			</view>
			<view class='sign-record'>
				<block v-for="item in 3" :key="index">
					<view class='list'>
						<view class='item'>
							<view class='data'>2021-10-10 </view>
							<view class='listn'>
								<block v-for=" (child,indexn) in 3" :key="indexn">
									<view class='itemn flex-between'>
										<view class="title">
											<view class='name line1'>哈哈哈哈
											</view>
											<view>2021-10-10 10：10：10</view>
											<view class="fail-msg">
												原因：不合格
											</view>
										</view>
										<view class='num font-color' v-if="indexn == 1">+100</view>
										<view class='num' v-else>-100</view>
									</view>
								</block>
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				type: 0,
				page: 1,
				limit: 15,
				loading: false,
				loadend: false,
				loadTitle: this.$t(`加载更多`),
				recordList: [],
				recordType: 0,
				recordCount: 0,
				extractCount: 0,
				times: []
			};
		},

		onLoad(options) {
			if (this.isLogin) {
				this.type = options.type;
			} else {
				toLogin();
			}
		},
		onShow: function() {
			uni.setNavigationBarTitle({
				title: "提现记录"
			});
			this.name = '提现总额';
			this.recordType = 4;
			this.getRecordList();
			this.getRecordListCount();
		},
		methods: {
			$t(text) {
				return text
			},
			getRecordList: function() {
				let that = this;
				let page = that.page;
				let limit = that.limit;
				let recordType = that.recordType;
				if (that.loading) return;
				if (that.loadend) return;
				that.loading = true;
				that.loadTitle = '';
				getCommissionInfo({
					page: page,
					limit: limit
				}, recordType).then(res => {
					for (let i = 0; i < res.data.time.length; i++) {
						if (!this.times.includes(res.data.time[i])) {
							this.times.push(res.data.time[i])
							this.recordList.push({
								time: res.data.time[i],
								child: []
							})
						}
					}
					for (let x = 0; x < this.times.length; x++) {
						for (let j = 0; j < res.data.list.length; j++) {
							if (this.times[x] === res.data.list[j].time_key) {
								this.recordList[x].child.push(res.data.list[j])
							}
						}
					}
					let loadend = res.data.list.length < that.limit;
					that.loadend = loadend;
					that.loadTitle = loadend ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
					that.page += 1;
					that.loading = false;
				}).catch(err => {
					that.loading = false;
					that.loadTitle = that.$t(`加载更多`);
				})
			},
			getRecordListCount: function() {
				let that = this;
				getSpreadInfo().then(res => {
					that.recordCount = res.data.commissionCount;
					that.extractCount = res.data.extractCount;
				});
			}
		},
		onReachBottom: function() {
			this.getRecordList();
		}
	}
</script>

<style scoped lang="scss">
	.promoterHeader {
		width: 100%;
		height: 220rpx
	}

	.promoterHeader .headerCon {
		width: 100%;
		height: 100%;
		padding: 0 88rpx 0 55rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		color: #fff;
		background-image: url('');
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}

	.promoterHeader .headerCon .name {
		margin-bottom: 10rpx;
	}

	.promoterHeader .headerCon .num {
		font-size: 50rpx;
	}

	.promoterHeader .headerCon .iconfont {
		font-size: 100rpx;
	}

	.bg-color {
		background-color: $u-primary;
	}

	.sign-record .list .item .data {
		height: 40px;
		line-height: 40px;
		padding: 0 15px;
		font-size: 12px;
		color: #666;

	}

	.sign-record .list .item .listn {
		background-color: #fff;
		font-size: 12px;
		color: #999;

	}

	.sign-record .list .item .listn .itemn {
		border-bottom: 1px solid #eee;
		padding: 15px;

	}

	.sign-record .list .item .listn .itemn .num {
		font-size: 18px;
		font-family: 'Guildford Pro';
		color: #16ac57;
	}

	.sign-record .list .item .listn .itemn .name {
		font-size: 14px;
		color: #282828;
		margin-bottom: 5px;
	}


	.sign-record .list .item .listn .itemn .num.font-color {
		color: red !important
	}

	.commission-details .promoterHeader .headerCon .money {
		font-size: 36rpx;
	}

	.commission-details .promoterHeader .headerCon .money .num {
		font-family: 'Guildford Pro';
	}

	.sign-record .list .item .listn .itemn .name {
		width: 100%;
		// max-width: 100%;
		white-space: break-spaces;
	}

	.sign-record .list .item .listn .itemn .title {
		padding-right: 30rpx;
		flex: 1;
	}
</style>